-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Physical Server relationship for Host summary page #1440
Conversation
@miq-bot add_labels compute/physical infrastructure, enhancement, textual summaries |
@@ -235,6 +235,10 @@ def textual_cluster | |||
h | |||
end | |||
|
|||
def textual_physical_server | |||
{:label => _("Physical Server"), :value => @record.physical_server.try(:name), :icon => "pficon pficon-server", :link => url_for(:controller => 'physical_server', :action => 'show', :id => @record.physical_server_id)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gabrielsvinha Not all hosts are expected to have a Physical Server associated with them, therefore, I recommend adding a conditional here.
{:label => _("Physical Server"), :value => @record.physical_server.try(:name), :icon => "pficon pficon-server", :link => url_for(:controller => 'physical_server', :action => 'show', :id => @record.physical_server_id)} if @record.physical_server_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done it.
Sure. But there is no point adding a count for physical servers in the listnav, their relationship is one-to-one. @AparnaKarve |
Ok, makes sense. |
76ddf16
to
e9d1e51
Compare
LGTM. @dclarizio Good to go. |
@gabrielsvinha I'm pretty sure we try to make the listnav match the summary screen contents and have seen links to single relationships, such as Host to Provider, in the listnav. @AparnaKarve is checking to see what we would do in the listnav if there is no relationship to an entity. |
@gabrielsvinha Let's revisit the discussion #1440 (comment) and #1440 (comment). So, for 1:1 Relationships, the listnav should display the Relationship and the link to that should land on the Summary page of the item. Please take a look at the screenshot below - Two things to note here.
Let me know if I can assist in any way. Thanks. |
@AparnaKarve @dclarizio Got it, working on it right now. |
e9d1e51
to
9635cc5
Compare
@AparnaKarve Done it: |
9635cc5
to
3dc9eea
Compare
Can you add |
{:label => _("Physical Server"), :value => "None", :icon => "pficon pficon-server"} | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flip the order here that way we do not have to use !
(negative conditional)
Also note the use of _("None")
which takes care of i18n.
if @record.physical_server_id.nil?
{:label => _("Physical Server"), :value => _("None"), :icon => "pficon pficon-server"}
else
{:label => _("Physical Server"), :value => @record.physical_server.try(:name), :icon => "pficon pficon-server", :link => url_for(:controller => 'physical_server', :action => 'show', :id => @record.physical_server_id)}
end
@@ -77,6 +77,12 @@ | |||
ems_infra_path(@record.ext_management_system), | |||
:title => _("Show this parent %{provider} for this %{host}") % {:host => host_title, :provider => ui_lookup(:table => "ems_infra")}) | |||
|
|||
- if role_allows?(:feature => "physical_server_show") && [email protected]_server.nil? | |||
%li | |||
= link_to("#{ui_lookup({:table => "physical_servers"})}: #{@record.physical_server.name}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the text is being shown as plural Physical Servers
... we need it to be singular.
I have created ManageIQ/manageiq#15275 with which ui_lookup
should work correctly and show the singular text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to this, you will also need to consider a case when a host does not have a Physical Server associated with it and then display Physical Server: None
in the listnav without a link.
- if role_allows?(:feature => "physical_server_show") && @record.physical_server.nil?
= li_link(:if => false, :text => "#{ui_lookup({:table => "physical_servers"})}: #{_('None')}")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done it.
8bf5f58
to
33e51b5
Compare
@@ -235,6 +235,14 @@ def textual_cluster | |||
h | |||
end | |||
|
|||
def textual_physical_server | |||
if @record.physical_server_id.nil? | |||
{:label => _("Physical Server"), :value => "None", :icon => "pficon pficon-server"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change "None"
to _("None")
@@ -119,6 +119,15 @@ | |||
:record_id => @record.id, | |||
:title => _("Show %{host} drift history") % {:host => host_title}) | |||
|
|||
- if role_allows?(:feature => "physical_server_show") && [email protected]_server.nil? | |||
%li | |||
= link_to("#{ui_lookup(:table => "physical_servers")}: #{@record.physical_server.name}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this ui_lookup(:table => "physical_servers")
(note the singular use of :table
as opposed to :tables
), I was expecting to see a singular Physical Server
, but instead seeing a plural (Physical Servers
)
@mzazrivec Any idea why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's the :table => physical _servers
, I tested :table => physical _server
and it looked good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm aware that :table => physical _server
seems to work but the table name is physical_servers
and not physical_server
. Hence, it does not seem right to use physical_server
The other option would be to go with :model => 'PhysicalServer'
, which works perfectly well for singular and plural cases
:model => 'PhysicalServer'
gives Physical Server
:models => 'PhysicalServer'
gives Physical Servers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know which one is the best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm inclined to use :model => 'PhysicalServer'
since it is working the way it's supposed to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Doing it.
@gabrielsvinha Other than the few minor things above, everything else looks good. |
33e51b5
to
3bbf51e
Compare
In the next iteration can you address the rubocop issue? |
@AparnaKarve Any idea what is this rubocop issue about? |
The haml-lint issue gets resolved if you write the %li
- physical_server_show = {:controller => "physical_server", :action => 'show', :id => @record.physical_server.id}
= link_to("#{ui_lookup(:table => "physical_servers")}: #{@record.physical_server.name}",
physical_server_show,
:title => _("Show Physical Server")) On second thoughts, don't worry about fixing this lint error. Leave it as is. Thanks. |
Do not worry, it will not be a problem. |
3bbf51e
to
a605548
Compare
Checked commit gabrielsvinha@a605548 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
- Adds physical server to host summary page in relationships label
@dclarizio This can be merged now. Thanks. |
Adds physical server link to Host summary page in relationship label.